{% extends "base.html" %}
{% block title %}{% endblock %}
{% block content %}
<br>
<form class="layui-form" action="" id="cross_srh" lay-filter="cross_srh">
    <div class="proxy_srh">
        <div class="layui-inline">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <label class="layui-form-label">项目*：</label>
                    <div class="layui-input-inline">
                        <select class="layui-select" name="project_id" id="project_id" lay-verify="" lay-search
                                lay-filter="project_id">
                            <option value="">请选择</option>
                            {% for d in projectAll %}
                            <option value="{{d.id}}">{{d.project_name}}</option>
                            {% endfor %}
                        </select>
                    </div>
                </div>
                <div class="layui-input-inline">
                    <label class="layui-form-label">项目阶段*：</label>
                    <div class="layui-input-inline">
                        <select class="layui-select" name="plan_type" id="plan_type" lay-verify="" lay-search
                                lay-filter="plan_type">
                            <option value='0'>需求阶段</option>
                            <option value='1'>开发阶段</option>
                            <option value='2'>单元测试</option>
                            <option value='3'>集成测试</option>
                            <option value='4'>冒烟测试</option>
                            <option value='5'>系统测试</option>
                            <option value='6'>回归测试</option>
                            <option value='7'>验收测试</option>
                            <option value='8'>线上验证</option>
                            <option value='9'>总结阶段</option>
                        </select>
                    </div>
                </div>

                <br><br>
                <div class="layui-input-inline">
                    <label class="layui-form-label">版本描述*：</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="project_version" id="project_version"
                               placeholder="请输入"
                               style="width:212px">
                    </div>
                </div>
                <div class="layui-input-inline">
                    <label class="layui-form-label">责任人*：</label>
                    <div class="layui-input-inline">
                        <select class="layui-select" name="work_charge" id="work_charge" lay-verify="" lay-search
                                lay-filter="work_charge">
                            <option value=''>请选择</option>
                                {% for d in userAll %}
                                <option value="{{d.id}}">{{d.userName}}</option>
                                {% endfor %}

                        </select>
                    </div>
                </div>
                <br><br>
                <div class="layui-input-inline">
                    <label class="layui-form-label">计划开始*：</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="work_p_start" id="work_p_start" placeholder="请输入"
                               style="width:212px">
                    </div>
                </div>
                <div class="layui-input-inline">
                    <label class="layui-form-label">计划结束*：</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="work_p_end" id="work_p_end" placeholder="请输入"
                               style="width:212px">
                    </div>
                </div>
                <br><br>
                <div class="layui-input-inline">
                    <label class="layui-form-label">实际结束：</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="work_end" id="work_end" placeholder="请输入"
                               style="width:212px">
                    </div>
                </div>
                <div class="layui-input-inline">
                    <label class="layui-form-label">任务状态：</label>
                    <div class="layui-input-inline">
                        <select class="layui-select" name="work_state" id="work_state" lay-verify="" lay-search
                                lay-filter="work_state">
                            <option value='0'>打开</option>
                            <option value='1'>完成</option>
                            <option value='2'>暂停</option>
                            <option value='3'>废弃</option>
                        </select>
                    </div>
                </div>



                <div class="layui-input-inline" style="display:none">
                    <label class="layui-form-label">：</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="id" id="id" placeholder="请输入"
                               style="width:212px">
                    </div>
                </div>
                <div class="layui-input-inline" style="display:none">
                    <label class="layui-form-label">：</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="up_person" id="up_person" placeholder="请输入"
                               style="width:212px">
                    </div>
                </div>
                <br><br>
                <div class="layui-input-inline" style="left:20px">
                    <span id="redTips" style="color:red">此时为新增状态，即会插入一条新数据!</span>
                </div>
                <div class="layui-inline" style="float:right;">
                    <button class="layui-btn" type="button" id="start" lay-submit lay-filter="start">保存所有</button>
                </div>

            </div>
        </div>

    </div>

</form>

<script>
    layui.use(['table','element'], function(){
          var table = layui.table
          ,form = layui.form;
          var $= layui.jquery;
          var element = layui.element;

          userId = layui.data('test').UserInfo.userId;
          $("#up_person").val(userId);


          CacheCasePlan = layui.data('test').RowCasePlan;

          if(CacheCasePlan == undefined){

          }else{
              form.val('cross_srh',{
                 project_id:CacheCasePlan.project_id
                 ,plan_type:CacheCasePlan.plan_type
                 ,project_version:CacheCasePlan.project_version
                 ,work_charge:CacheCasePlan.work_charge
                 ,work_p_start:CacheCasePlan.work_p_start
                 ,work_p_end:CacheCasePlan.work_p_end
                 ,work_state:CacheCasePlan.work_state
                 ,work_end:CacheCasePlan.work_end
                 ,id:CacheCasePlan.id
                 ,up_person:userId
              });

              form.render();
          }
          if($("#id").val()!=""){
             $("#redTips").html('<span id="redTips" style="color:red;left:20px">此时为更新状态!</span>');
          }

          form.on('submit(start)', function(data){
                if(data.field.project_id == ""||data.field.plan_type == ""||data.field.project_version == ""||data.field.work_state == ""||data.field.work_p_start == ""||data.field.work_p_end == ""){
                    layer.msg("项目、版本描述、责任人、计划开始、计划结束 必须填写!");
                    return false;
                }
                if(data.field.work_state == 1 && data.field.work_end==""){
                    layer.msg("状态为完成时，必须填写实际完成时间!");
                    return false;
                }

                $.ajax({
                         //发出请求
                        type:"POST",
                        url:"/casePlan/main/manage",
                        contentType: 'application/json; charset=utf-8',
                        dataType:"json",
                        data:JSON.stringify(data.field),
                        success: function(result){
                            if(result.id){
                                $("#id").val(result.id);
                                if($("#id").val()!=""){
                                    $("#redTips").html('<span id="redTips" style="color:red;left:20px">此时为更新状态!</span>');
                                }
                                layer.msg("保存成功");
                            }

                        }
                });
          });
          form.render();
    });




</script>
<script>
//时间控件
layui.use('laydate', function(){
  var laydate = layui.laydate;
  laydate.render({
    elem: '#work_p_end',
    type:'date',
    format:'yyyy-MM-dd',
    trigger: 'click'
  });
  laydate.render({
    elem: '#work_p_start',
    type:'date',
    format:'yyyy-MM-dd',
    trigger: 'click'
  });
  laydate.render({
    elem: '#work_end',
    type:'date',
    format:'yyyy-MM-dd',
    trigger: 'click'
  });

});







</script>

{% endblock %}